<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>选择排序</title>
</head>
<body>
<h3>选择排序</h3>
<script>
	function selectSort(arr){
		var len = arr.length; 
		var minIndex , temp;
		for(var i=0;i<len-1;i++){
			minIndex =i;
			for(var j=i+1;j<len;j++){
				if(arr[j] < arr[minIndex]){
					minIndex = j;
				}
			}
			temp =arr[i];
			arr[i] =arr[minIndex];
			arr[minIndex] = temp;
		}
		return arr;
	}
	console.log( selectSort([1,3,8,10,4,5]) )
</script>
</body>
</html>
